3.3.21 \(\int \frac {\cot ^2(e+f x)}{a+b \tan ^2(e+f x)} \, dx\) [221]

3.3.21.1 Optimal result
3.3.21.2 Mathematica [A] (verified)
3.3.21.3 Rubi [A] (verified)
3.3.21.4 Maple [A] (verified)
3.3.21.5 Fricas [A] (verification not implemented)
3.3.21.6 Sympy [B] (verification not implemented)
3.3.21.7 Maxima [A] (verification not implemented)
3.3.21.8 Giac [A] (verification not implemented)
3.3.21.9 Mupad [B] (verification not implemented)

3.3.21.1 Optimal result

Integrand size = 23, antiderivative size = 64 \[ \int \frac {\cot ^2(e+f x)}{a+b \tan ^2(e+f x)} \, dx=-\frac {x}{a-b}+\frac {b^{3/2} \arctan \left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a}}\right )}{a^{3/2} (a-b) f}-\frac {\cot (e+f x)}{a f} \]

output
-x/(a-b)+b^(3/2)*arctan(b^(1/2)*tan(f*x+e)/a^(1/2))/a^(3/2)/(a-b)/f-cot(f* 
x+e)/a/f
 
3.3.21.2 Mathematica [A] (verified)

Time = 0.29 (sec) , antiderivative size = 68, normalized size of antiderivative = 1.06 \[ \int \frac {\cot ^2(e+f x)}{a+b \tan ^2(e+f x)} \, dx=\frac {b^{3/2} \arctan \left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a}}\right )-\sqrt {a} (a (e+f x)+(a-b) \cot (e+f x))}{a^{3/2} (a-b) f} \]

input
Integrate[Cot[e + f*x]^2/(a + b*Tan[e + f*x]^2),x]
 
output
(b^(3/2)*ArcTan[(Sqrt[b]*Tan[e + f*x])/Sqrt[a]] - Sqrt[a]*(a*(e + f*x) + ( 
a - b)*Cot[e + f*x]))/(a^(3/2)*(a - b)*f)
 
3.3.21.3 Rubi [A] (verified)

Time = 0.28 (sec) , antiderivative size = 75, normalized size of antiderivative = 1.17, number of steps used = 8, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.304, Rules used = {3042, 4153, 382, 25, 397, 216, 218}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {\cot ^2(e+f x)}{a+b \tan ^2(e+f x)} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {1}{\tan (e+f x)^2 \left (a+b \tan (e+f x)^2\right )}dx\)

\(\Big \downarrow \) 4153

\(\displaystyle \frac {\int \frac {\cot ^2(e+f x)}{\left (\tan ^2(e+f x)+1\right ) \left (b \tan ^2(e+f x)+a\right )}d\tan (e+f x)}{f}\)

\(\Big \downarrow \) 382

\(\displaystyle \frac {\frac {\int -\frac {b \tan ^2(e+f x)+a+b}{\left (\tan ^2(e+f x)+1\right ) \left (b \tan ^2(e+f x)+a\right )}d\tan (e+f x)}{a}-\frac {\cot (e+f x)}{a}}{f}\)

\(\Big \downarrow \) 25

\(\displaystyle \frac {-\frac {\int \frac {b \tan ^2(e+f x)+a+b}{\left (\tan ^2(e+f x)+1\right ) \left (b \tan ^2(e+f x)+a\right )}d\tan (e+f x)}{a}-\frac {\cot (e+f x)}{a}}{f}\)

\(\Big \downarrow \) 397

\(\displaystyle \frac {-\frac {\frac {a \int \frac {1}{\tan ^2(e+f x)+1}d\tan (e+f x)}{a-b}-\frac {b^2 \int \frac {1}{b \tan ^2(e+f x)+a}d\tan (e+f x)}{a-b}}{a}-\frac {\cot (e+f x)}{a}}{f}\)

\(\Big \downarrow \) 216

\(\displaystyle \frac {-\frac {\frac {a \arctan (\tan (e+f x))}{a-b}-\frac {b^2 \int \frac {1}{b \tan ^2(e+f x)+a}d\tan (e+f x)}{a-b}}{a}-\frac {\cot (e+f x)}{a}}{f}\)

\(\Big \downarrow \) 218

\(\displaystyle \frac {-\frac {\frac {a \arctan (\tan (e+f x))}{a-b}-\frac {b^{3/2} \arctan \left (\frac {\sqrt {b} \tan (e+f x)}{\sqrt {a}}\right )}{\sqrt {a} (a-b)}}{a}-\frac {\cot (e+f x)}{a}}{f}\)

input
Int[Cot[e + f*x]^2/(a + b*Tan[e + f*x]^2),x]
 
output
(-(((a*ArcTan[Tan[e + f*x]])/(a - b) - (b^(3/2)*ArcTan[(Sqrt[b]*Tan[e + f* 
x])/Sqrt[a]])/(Sqrt[a]*(a - b)))/a) - Cot[e + f*x]/a)/f
 

3.3.21.3.1 Defintions of rubi rules used

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

rule 216
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*A 
rcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /; FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a 
, 0] || GtQ[b, 0])
 

rule 218
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/R 
t[a/b, 2]], x] /; FreeQ[{a, b}, x] && PosQ[a/b]
 

rule 382
Int[((e_.)*(x_))^(m_)*((a_) + (b_.)*(x_)^2)^(p_)*((c_) + (d_.)*(x_)^2)^(q_) 
, x_Symbol] :> Simp[(e*x)^(m + 1)*(a + b*x^2)^(p + 1)*((c + d*x^2)^(q + 1)/ 
(a*c*e*(m + 1))), x] - Simp[1/(a*c*e^2*(m + 1))   Int[(e*x)^(m + 2)*(a + b* 
x^2)^p*(c + d*x^2)^q*Simp[(b*c + a*d)*(m + 3) + 2*(b*c*p + a*d*q) + b*d*(m 
+ 2*p + 2*q + 5)*x^2, x], x], x] /; FreeQ[{a, b, c, d, e, p, q}, x] && NeQ[ 
b*c - a*d, 0] && LtQ[m, -1] && IntBinomialQ[a, b, c, d, e, m, 2, p, q, x]
 

rule 397
Int[((e_) + (f_.)*(x_)^2)/(((a_) + (b_.)*(x_)^2)*((c_) + (d_.)*(x_)^2)), x_ 
Symbol] :> Simp[(b*e - a*f)/(b*c - a*d)   Int[1/(a + b*x^2), x], x] - Simp[ 
(d*e - c*f)/(b*c - a*d)   Int[1/(c + d*x^2), x], x] /; FreeQ[{a, b, c, d, e 
, f}, x]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4153
Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + 
(f_.)*(x_)])^(n_))^(p_.), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x], 
 x]}, Simp[c*(ff/f)   Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2 + f 
f^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, 
n, p}, x] && (IGtQ[p, 0] || EqQ[n, 2] || EqQ[n, 4] || (IntegerQ[p] && Ratio 
nalQ[n]))
 
3.3.21.4 Maple [A] (verified)

Time = 0.17 (sec) , antiderivative size = 68, normalized size of antiderivative = 1.06

method result size
derivativedivides \(\frac {-\frac {\arctan \left (\tan \left (f x +e \right )\right )}{a -b}-\frac {1}{a \tan \left (f x +e \right )}+\frac {b^{2} \arctan \left (\frac {b \tan \left (f x +e \right )}{\sqrt {a b}}\right )}{a \left (a -b \right ) \sqrt {a b}}}{f}\) \(68\)
default \(\frac {-\frac {\arctan \left (\tan \left (f x +e \right )\right )}{a -b}-\frac {1}{a \tan \left (f x +e \right )}+\frac {b^{2} \arctan \left (\frac {b \tan \left (f x +e \right )}{\sqrt {a b}}\right )}{a \left (a -b \right ) \sqrt {a b}}}{f}\) \(68\)
risch \(-\frac {x}{a -b}-\frac {2 i}{f a \left ({\mathrm e}^{2 i \left (f x +e \right )}-1\right )}-\frac {\sqrt {-a b}\, b \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+\frac {2 i \sqrt {-a b}+a +b}{a -b}\right )}{2 a^{2} \left (a -b \right ) f}+\frac {\sqrt {-a b}\, b \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {2 i \sqrt {-a b}-a -b}{a -b}\right )}{2 a^{2} \left (a -b \right ) f}\) \(145\)

input
int(cot(f*x+e)^2/(a+b*tan(f*x+e)^2),x,method=_RETURNVERBOSE)
 
output
1/f*(-1/(a-b)*arctan(tan(f*x+e))-1/a/tan(f*x+e)+1/a*b^2/(a-b)/(a*b)^(1/2)* 
arctan(b*tan(f*x+e)/(a*b)^(1/2)))
 
3.3.21.5 Fricas [A] (verification not implemented)

Time = 0.28 (sec) , antiderivative size = 243, normalized size of antiderivative = 3.80 \[ \int \frac {\cot ^2(e+f x)}{a+b \tan ^2(e+f x)} \, dx=\left [-\frac {4 \, a f x \tan \left (f x + e\right ) + b \sqrt {-\frac {b}{a}} \log \left (\frac {b^{2} \tan \left (f x + e\right )^{4} - 6 \, a b \tan \left (f x + e\right )^{2} + a^{2} - 4 \, {\left (a b \tan \left (f x + e\right )^{3} - a^{2} \tan \left (f x + e\right )\right )} \sqrt {-\frac {b}{a}}}{b^{2} \tan \left (f x + e\right )^{4} + 2 \, a b \tan \left (f x + e\right )^{2} + a^{2}}\right ) \tan \left (f x + e\right ) + 4 \, a - 4 \, b}{4 \, {\left (a^{2} - a b\right )} f \tan \left (f x + e\right )}, -\frac {2 \, a f x \tan \left (f x + e\right ) - b \sqrt {\frac {b}{a}} \arctan \left (\frac {{\left (b \tan \left (f x + e\right )^{2} - a\right )} \sqrt {\frac {b}{a}}}{2 \, b \tan \left (f x + e\right )}\right ) \tan \left (f x + e\right ) + 2 \, a - 2 \, b}{2 \, {\left (a^{2} - a b\right )} f \tan \left (f x + e\right )}\right ] \]

input
integrate(cot(f*x+e)^2/(a+b*tan(f*x+e)^2),x, algorithm="fricas")
 
output
[-1/4*(4*a*f*x*tan(f*x + e) + b*sqrt(-b/a)*log((b^2*tan(f*x + e)^4 - 6*a*b 
*tan(f*x + e)^2 + a^2 - 4*(a*b*tan(f*x + e)^3 - a^2*tan(f*x + e))*sqrt(-b/ 
a))/(b^2*tan(f*x + e)^4 + 2*a*b*tan(f*x + e)^2 + a^2))*tan(f*x + e) + 4*a 
- 4*b)/((a^2 - a*b)*f*tan(f*x + e)), -1/2*(2*a*f*x*tan(f*x + e) - b*sqrt(b 
/a)*arctan(1/2*(b*tan(f*x + e)^2 - a)*sqrt(b/a)/(b*tan(f*x + e)))*tan(f*x 
+ e) + 2*a - 2*b)/((a^2 - a*b)*f*tan(f*x + e))]
 
3.3.21.6 Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 522 vs. \(2 (48) = 96\).

Time = 7.76 (sec) , antiderivative size = 522, normalized size of antiderivative = 8.16 \[ \int \frac {\cot ^2(e+f x)}{a+b \tan ^2(e+f x)} \, dx=\begin {cases} \tilde {\infty } x & \text {for}\: a = 0 \wedge b = 0 \wedge e = 0 \wedge f = 0 \\\frac {- x - \frac {\cot {\left (e + f x \right )}}{f}}{a} & \text {for}\: b = 0 \\\frac {x + \frac {1}{f \tan {\left (e + f x \right )}} - \frac {1}{3 f \tan ^{3}{\left (e + f x \right )}}}{b} & \text {for}\: a = 0 \\- \frac {3 f x \tan ^{3}{\left (e + f x \right )}}{2 b f \tan ^{3}{\left (e + f x \right )} + 2 b f \tan {\left (e + f x \right )}} - \frac {3 f x \tan {\left (e + f x \right )}}{2 b f \tan ^{3}{\left (e + f x \right )} + 2 b f \tan {\left (e + f x \right )}} - \frac {3 \tan ^{2}{\left (e + f x \right )}}{2 b f \tan ^{3}{\left (e + f x \right )} + 2 b f \tan {\left (e + f x \right )}} - \frac {2}{2 b f \tan ^{3}{\left (e + f x \right )} + 2 b f \tan {\left (e + f x \right )}} & \text {for}\: a = b \\\frac {\tilde {\infty } x}{a} & \text {for}\: e = - f x \\\frac {x \cot ^{2}{\left (e \right )}}{a + b \tan ^{2}{\left (e \right )}} & \text {for}\: f = 0 \\- \frac {2 a f x \sqrt {- \frac {a}{b}} \tan {\left (e + f x \right )}}{2 a^{2} f \sqrt {- \frac {a}{b}} \tan {\left (e + f x \right )} - 2 a b f \sqrt {- \frac {a}{b}} \tan {\left (e + f x \right )}} - \frac {2 a \sqrt {- \frac {a}{b}}}{2 a^{2} f \sqrt {- \frac {a}{b}} \tan {\left (e + f x \right )} - 2 a b f \sqrt {- \frac {a}{b}} \tan {\left (e + f x \right )}} + \frac {2 b \sqrt {- \frac {a}{b}}}{2 a^{2} f \sqrt {- \frac {a}{b}} \tan {\left (e + f x \right )} - 2 a b f \sqrt {- \frac {a}{b}} \tan {\left (e + f x \right )}} + \frac {b \log {\left (- \sqrt {- \frac {a}{b}} + \tan {\left (e + f x \right )} \right )} \tan {\left (e + f x \right )}}{2 a^{2} f \sqrt {- \frac {a}{b}} \tan {\left (e + f x \right )} - 2 a b f \sqrt {- \frac {a}{b}} \tan {\left (e + f x \right )}} - \frac {b \log {\left (\sqrt {- \frac {a}{b}} + \tan {\left (e + f x \right )} \right )} \tan {\left (e + f x \right )}}{2 a^{2} f \sqrt {- \frac {a}{b}} \tan {\left (e + f x \right )} - 2 a b f \sqrt {- \frac {a}{b}} \tan {\left (e + f x \right )}} & \text {otherwise} \end {cases} \]

input
integrate(cot(f*x+e)**2/(a+b*tan(f*x+e)**2),x)
 
output
Piecewise((zoo*x, Eq(a, 0) & Eq(b, 0) & Eq(e, 0) & Eq(f, 0)), ((-x - cot(e 
 + f*x)/f)/a, Eq(b, 0)), ((x + 1/(f*tan(e + f*x)) - 1/(3*f*tan(e + f*x)**3 
))/b, Eq(a, 0)), (-3*f*x*tan(e + f*x)**3/(2*b*f*tan(e + f*x)**3 + 2*b*f*ta 
n(e + f*x)) - 3*f*x*tan(e + f*x)/(2*b*f*tan(e + f*x)**3 + 2*b*f*tan(e + f* 
x)) - 3*tan(e + f*x)**2/(2*b*f*tan(e + f*x)**3 + 2*b*f*tan(e + f*x)) - 2/( 
2*b*f*tan(e + f*x)**3 + 2*b*f*tan(e + f*x)), Eq(a, b)), (zoo*x/a, Eq(e, -f 
*x)), (x*cot(e)**2/(a + b*tan(e)**2), Eq(f, 0)), (-2*a*f*x*sqrt(-a/b)*tan( 
e + f*x)/(2*a**2*f*sqrt(-a/b)*tan(e + f*x) - 2*a*b*f*sqrt(-a/b)*tan(e + f* 
x)) - 2*a*sqrt(-a/b)/(2*a**2*f*sqrt(-a/b)*tan(e + f*x) - 2*a*b*f*sqrt(-a/b 
)*tan(e + f*x)) + 2*b*sqrt(-a/b)/(2*a**2*f*sqrt(-a/b)*tan(e + f*x) - 2*a*b 
*f*sqrt(-a/b)*tan(e + f*x)) + b*log(-sqrt(-a/b) + tan(e + f*x))*tan(e + f* 
x)/(2*a**2*f*sqrt(-a/b)*tan(e + f*x) - 2*a*b*f*sqrt(-a/b)*tan(e + f*x)) - 
b*log(sqrt(-a/b) + tan(e + f*x))*tan(e + f*x)/(2*a**2*f*sqrt(-a/b)*tan(e + 
 f*x) - 2*a*b*f*sqrt(-a/b)*tan(e + f*x)), True))
 
3.3.21.7 Maxima [A] (verification not implemented)

Time = 0.32 (sec) , antiderivative size = 65, normalized size of antiderivative = 1.02 \[ \int \frac {\cot ^2(e+f x)}{a+b \tan ^2(e+f x)} \, dx=\frac {\frac {b^{2} \arctan \left (\frac {b \tan \left (f x + e\right )}{\sqrt {a b}}\right )}{{\left (a^{2} - a b\right )} \sqrt {a b}} - \frac {f x + e}{a - b} - \frac {1}{a \tan \left (f x + e\right )}}{f} \]

input
integrate(cot(f*x+e)^2/(a+b*tan(f*x+e)^2),x, algorithm="maxima")
 
output
(b^2*arctan(b*tan(f*x + e)/sqrt(a*b))/((a^2 - a*b)*sqrt(a*b)) - (f*x + e)/ 
(a - b) - 1/(a*tan(f*x + e)))/f
 
3.3.21.8 Giac [A] (verification not implemented)

Time = 0.66 (sec) , antiderivative size = 82, normalized size of antiderivative = 1.28 \[ \int \frac {\cot ^2(e+f x)}{a+b \tan ^2(e+f x)} \, dx=\frac {\frac {{\left (\pi \left \lfloor \frac {f x + e}{\pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (b\right ) + \arctan \left (\frac {b \tan \left (f x + e\right )}{\sqrt {a b}}\right )\right )} b^{2}}{{\left (a^{2} - a b\right )} \sqrt {a b}} - \frac {f x + e}{a - b} - \frac {1}{a \tan \left (f x + e\right )}}{f} \]

input
integrate(cot(f*x+e)^2/(a+b*tan(f*x+e)^2),x, algorithm="giac")
 
output
((pi*floor((f*x + e)/pi + 1/2)*sgn(b) + arctan(b*tan(f*x + e)/sqrt(a*b)))* 
b^2/((a^2 - a*b)*sqrt(a*b)) - (f*x + e)/(a - b) - 1/(a*tan(f*x + e)))/f
 
3.3.21.9 Mupad [B] (verification not implemented)

Time = 11.08 (sec) , antiderivative size = 438, normalized size of antiderivative = 6.84 \[ \int \frac {\cot ^2(e+f x)}{a+b \tan ^2(e+f x)} \, dx=\frac {a^2\,b-a^3}{f\,\left (a^4\,\mathrm {tan}\left (e+f\,x\right )-a^3\,b\,\mathrm {tan}\left (e+f\,x\right )\right )}+\frac {\mathrm {atan}\left (\frac {a^6\,b\,\mathrm {tan}\left (e+f\,x\right )\,\sqrt {-a^3\,b^3}\,1{}\mathrm {i}-a^3\,b^4\,\mathrm {tan}\left (e+f\,x\right )\,\sqrt {-a^3\,b^3}\,1{}\mathrm {i}}{a^5\,b^5-a^8\,b^2}\right )\,\sqrt {-a^3\,b^3}\,1{}\mathrm {i}-a^3\,\mathrm {atan}\left (\frac {\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (2\,a^5\,b^3+2\,a^3\,b^5\right )+\frac {\left (4\,a^5\,b^4-4\,a^4\,b^5+4\,a^6\,b^3-4\,a^7\,b^2+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (8\,a^8\,b^2-8\,a^7\,b^3-8\,a^6\,b^4+8\,a^5\,b^5\right )\,1{}\mathrm {i}}{2\,a-2\,b}\right )\,1{}\mathrm {i}}{2\,a-2\,b}}{2\,a-2\,b}+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (2\,a^5\,b^3+2\,a^3\,b^5\right )+\frac {\left (4\,a^4\,b^5-4\,a^5\,b^4-4\,a^6\,b^3+4\,a^7\,b^2+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (8\,a^8\,b^2-8\,a^7\,b^3-8\,a^6\,b^4+8\,a^5\,b^5\right )\,1{}\mathrm {i}}{2\,a-2\,b}\right )\,1{}\mathrm {i}}{2\,a-2\,b}}{2\,a-2\,b}}{2\,a^5\,b^2+2\,a^4\,b^3+2\,a^3\,b^4}\right )}{f\,\left (a^3\,b-a^4\right )} \]

input
int(cot(e + f*x)^2/(a + b*tan(e + f*x)^2),x)
 
output
(a^2*b - a^3)/(f*(a^4*tan(e + f*x) - a^3*b*tan(e + f*x))) + (atan((a^6*b*t 
an(e + f*x)*(-a^3*b^3)^(1/2)*1i - a^3*b^4*tan(e + f*x)*(-a^3*b^3)^(1/2)*1i 
)/(a^5*b^5 - a^8*b^2))*(-a^3*b^3)^(1/2)*1i - a^3*atan(((((4*a^5*b^4 - 4*a^ 
4*b^5 + 4*a^6*b^3 - 4*a^7*b^2 + (tan(e + f*x)*(8*a^5*b^5 - 8*a^6*b^4 - 8*a 
^7*b^3 + 8*a^8*b^2)*1i)/(2*a - 2*b))*1i)/(2*a - 2*b) + tan(e + f*x)*(2*a^3 
*b^5 + 2*a^5*b^3))/(2*a - 2*b) + (((4*a^4*b^5 - 4*a^5*b^4 - 4*a^6*b^3 + 4* 
a^7*b^2 + (tan(e + f*x)*(8*a^5*b^5 - 8*a^6*b^4 - 8*a^7*b^3 + 8*a^8*b^2)*1i 
)/(2*a - 2*b))*1i)/(2*a - 2*b) + tan(e + f*x)*(2*a^3*b^5 + 2*a^5*b^3))/(2* 
a - 2*b))/(2*a^3*b^4 + 2*a^4*b^3 + 2*a^5*b^2)))/(f*(a^3*b - a^4))